﻿using System;
using System.ComponentModel;
using System.Data;
using System.Linq;
using Kingdee.BOS;
using Kingdee.BOS.App.Data;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Log;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;
using Kingdee.K3.FIN.IV.Business.PlugIn.GoldenTax;

namespace ZKHY.BUSSINESS.PLUGIN
{
	[HotUpdate]
	[Description("费用报销 表单插件")]
	public class IVEditForRecInv_Extend : IVEditForRecInv
	{
		public override void DataChanged(DataChangedEventArgs e)
		{
			base.DataChanged(e);
			bool flag = e.Field.Key.Equals("FRecInvBillNo");
			if (flag)
			{
				bool flag2 = !ObjectUtils.IsNullOrEmptyOrWhiteSpace(e.NewValue);
				if (flag2)
				{
					string text = "/*dialect*/select FIVNUMBER,FOPENDATE\r\n                    from T_IV_RECEIVEDINVOICE\r\n                    where fbillno='" + string.Join("','", ObjectUtils.GetString(e.NewValue).Split(new char[]
					{
						','
					})) + "'";
					FileLog.WriteLogFile("D:/log.txt", DateTime.Now.ToString() + " sql:" + text);
					DynamicObjectCollection dynamicObjectCollection = DBUtils.ExecuteDynamicObject(base.Context, text, null, null, CommandType.Text, Array.Empty<SqlParam>());
					bool flag3 = dynamicObjectCollection != null;
					if (flag3)
					{
						string text2 = string.Join("/", from p in dynamicObjectCollection
						select ObjectUtils.GetString(p["FIVNUMBER"]));
						base.View.Model.SetValue("F_UNW_Text_tzk", text2, e.Row);
						base.View.Model.SetValue("FAPPROVEDATE", dynamicObjectCollection[0]["FOPENDATE"], e.Row);
					}
				}
			}
		}
	}
}
